#!/usr/bin/env bash
dt="`date -d "$d  0 days ago "  "+%Y-%m-%d"`"
mysql -ureadonly -preadonly123 -h192.168.0.49<<EOF
use jiayou;
select a.id,a.coupon_title,b.tactics_title,
from_unixtime(a.created,'%Y-%m-%d'),from_unixtime(a.updated,'%Y-%m-%d'),
case
when a.tactics_type = 'order' then '活动赠送'
when a.tactics_type = 'reissued' then '人工赠送'
when a.tactics_type = 'score' then '积分兑换'
else '其他活动发放' end as tactics_type  ,
case
when a.coupon_type = 1 then '燃油满减券'
when a.coupon_type = 2 then '燃油折扣券'
when a.coupon_type = 3 then '非油满减券'
else null end as coupon_type,
a.discount_amount,a.use_shop_id,
case
when a.coupon_statue = 1 then '可用'
when a.coupon_statue = 3 then '已使用'
when a.coupon_statue = 9 then '已过期'
else null end as coupon_statue
from coupon_info as a
join coupon_send_tactics as b
on a.send_tactics_id = b.id
where from_unixtime(a.updated,'%Y-%m-%d')='$dt';
EOF